package com.eqdd.yiqidian.utils;

import java.lang.reflect.Field;

/**
 * Created by lv on 17-9-22.
 */

public class ReflectUtil {
    public static String getHeadField(Object o, String field) {
        try {
            Field declaredField = o.getClass().getDeclaredField(field);
            declaredField.setAccessible(true);
            return PinYinUtil.head((String) declaredField.get(o));
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("反射异常");
        }
        return "";
    }

    public static String getField(Object o, String field) {
        try {
            Field declaredField = o.getClass().getDeclaredField(field);
            declaredField.setAccessible(true);
            return (String) declaredField.get(o);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("反射异常");
        }
        return "";
    }
}
